import { upload, post, download } from '@/utils/request'

// 商品分类
export async function getSelectOptions(params) {
  return post({
    url: '/drug-safety/yjCategory/getCategory/v001',
    params
  })
}
// 采购入库
export async function getSearchList(params) {
  return post({
    url: '/drug-safety/yjPurIn/getDataCgrk/v001',
    params
  })
}

export async function directReport(params) {
  return download({
    url: '/drug-safety/yjPurIn/directDownloadFile/v001',
    responseType: 'blob',
    params
  })
}

export async function exportFile(params) {
  return download({
    url: '/drug-safety/yjPurIn/exportFile/v001',
    responseType: 'blob',
    params
  })
}

export async function uploadFile(params) {
  return upload({
    url: '/drug-safety/yjPurIn/uploadFile/v001',
    responseType: 'blob',
    params
  })
}
// 库存现有量
export async function getDataKcjl(params) {
  return post({
    url: '/drug-safety/yjAngleBalance/getDataKcjl/v001',
    params
  })
}

export async function directReportAB(params) {
  return download({
    url: '/drug-safety/yjAngleBalance/directDownloadFile/v001',
    responseType: 'blob',
    params
  })
}

export async function exportFileAB(params) {
  return download({
    url: '/drug-safety/yjAngleBalance/exportFile/v001',
    responseType: 'blob',
    params
  })
}

export async function uploadFileAB(params) {
  return upload({
    url: '/drug-safety/yjAngleBalance/uploadFile/v001',
    responseType: 'blob',
    params
  })
}
// 批发出库
export async function getDataXsck(params) {
  return post({
    url: '/drug-safety/yjSaleOut/getDataXsck/v001',
    params
  })
}

export async function directReportSale(params) {
  return download({
    url: '/drug-safety/yjSaleOut/directDownloadFile/v001',
    responseType: 'blob',
    params
  })
}

export async function exportFileSale(params) {
  return download({
    url: '/drug-safety/yjSaleOut/exportFile/v001',
    responseType: 'blob',
    params
  })
}

export async function uploadFileSale(params) {
  return upload({
    url: '/drug-safety/yjSaleOut/uploadFile/v001',
    responseType: 'blob',
    params
  })
}

export async function uploadYjj(params) {
  const url = process.env.NODE_ENV === 'development' ? 'https://lx.gdfda.gov.cn:20830/data/clientAccept/toUploadFile.do' : 'https://qy.gdfda.gov.cn:8445/data/clientAccept/toUploadFile.do'
  return upload({
    url: url,
    params
  })
}
// 测试服ip
// const sip = 'https://lx.gdfda.gov.cn:20830'
// const sip = 'https://qy.gdfda.gov.cn:8445'
// const urlUpload = sip + '/data/clientAccept/toUploadFile.do'

/**
 * @description 上传证书文件
 * @param signFile required 文件
 * @param token
 * @param type 文件类型，0签名证书，1加密证书
 * @return {Promise<void>}
 */
export async function setUploadFile(params) {
  return upload({
    url: '/drug-safety/yjCertificate/uploadFile/v001',
    params
  })
}

/**
 * description 获取证书上传状态
 * @param type 文件类型，0签名证书，1加密证书
 * @return {Promise<void>}
 */
export async function getCertificate(params) {
  return post({
    url: '/drug-safety/yjCertificate/getCertificate/v001',
    params
  })
}
